#ifndef __SLAM_FEATURE_HPP__
#define __SLAM_FEATURE_HPP__

#include <memory>
#include <opencv2/highgui.hpp>

namespace slam {
template <class FeatureType, class AttrType>
class Feature
{

public:
    Feature() {}
    ~Feature() {}

    bool Init(AttrType& attrInfo);
    bool Extract(cv::Mat image);
    bool Clean();

    void DrawKeyPoints();

    std::vector<cv::KeyPoint> KeyPoint(void) const;

private:
    std::shared_ptr<FeatureType> instance_;
    AttrType attrInfo_;

}; // class Feature

template <class FeatureType, class AttrType>
bool Feature<FeatureType, AttrType>::Init(AttrType& attrInfo)
{
    // todo: 新建日志
    // 新建feature对象
    if (instance_.get() == nullptr) {
        instance_ = std::make_shared<FeatureType>();
    }

    attrInfo_ = attrInfo;
    
    return instance_->Init(attrInfo_);
}

template <class FeatureType, class AttrType>
bool Feature<FeatureType, AttrType>::Extract(cv::Mat image)
{
    return instance_->Extract(image);
}

template <class FeatureType, class AttrType>
bool Feature<FeatureType, AttrType>::Clean()
{
    return instance_->Clean();
}

template <class FeatureType, class AttrType>
std::vector<cv::KeyPoint> Feature<FeatureType, AttrType>::KeyPoint() const
{
    return instance_->KeyPoint();
}

template <class FeatureType, class AttrType>
void Feature<FeatureType, AttrType>::DrawKeyPoints()
{
    return instance_->DrawKeyPoints();
}

} // namespace slam
#endif // __SLAM_IFEATURE_HPP__